Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): custom ws headers support #1729

Merged
merged 1 commit into from
Jul 31, 2024
Merged

feat(cli): custom ws headers support #1729

merged 1 commit into from
Jul 31, 2024

Conversation

ysfscream
Copy link
Member

@ysfscream ysfscream commented Jul 30, 2024

PR Checklist

If you have any questions, you can refer to the Contributing Guide

What is the current behavior?

Currently, the MQTTX command-line tool does not allow customization of WebSocket headers when using WebSocket connections.

Issue Number

Example: #1722

What is the new behavior?

Added the ability to customize WebSocket headers through the -wh parameter in the command line. For example:

mqttx sub -t test -wh "hello: test" -wh "auth: token" -l ws -p 8083

Does this PR introduce a breaking change?

  • Yes
  • No

Specific Instructions

When reviewing this PR, please note the following:

  1. This feature is implemented only in the command-line tool running in a Node.js environment.
  2. Test scenarios with multiple -wh parameters to ensure multiple headers are correctly added.
  3. Verify that the parameter is properly ignored for non-WebSocket connections.

Other information

This feature comes from user requests, allowing users to customize headers when using WebSocket connections, increasing connection flexibility. For example, users can add authentication information or other custom data.

It's important to note that this feature is only supported in the command-line tool running in a Node.js environment. Due to browser security restrictions, the Desktop and Web versions of MQTTX cannot modify WebSocket headers, and therefore cannot implement this feature. This is a known limitation, and detailed information can be found in the related discussion in the MQTT.js project: mqttjs/MQTT.js#856

This new feature will provide more connection options for command-line users, especially useful in WebSocket connection scenarios that require special authentication or custom headers.

@ysfscream ysfscream added enhancement New feature or request feature This pr is a feature CLI MQTTX CLI labels Jul 30, 2024
@ysfscream ysfscream added this to the v1.11.0 milestone Jul 30, 2024
@ysfscream ysfscream requested a review from Red-Asuka July 30, 2024 10:02
@ysfscream ysfscream self-assigned this Jul 30, 2024
@Red-Asuka Red-Asuka merged commit 105c209 into main Jul 31, 2024
4 checks passed
@Red-Asuka Red-Asuka deleted the ysf/cli branch July 31, 2024 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI MQTTX CLI enhancement New feature or request feature This pr is a feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants